' Strict
SuperStrict

' Modules
Import BRL.Max2D
'Import BtbN.GLDraw2D

' DrawCircle
Function DrawCircle(x:Float, y:Float, radius:Float)
	DrawOval x - radius, y - radius, radius * 2, radius * 2
End Function

' DrawRectOutline
Function DrawRectOutline(x:Int, y:Int, width:Int, height:Int, border:Int = 1)
	DrawRect x, y, width, border
	DrawRect x, y, border, height
	DrawRect x + width - border, y, border, height
	DrawRect x, y + height - border, width, border
End Function

' DrawImageRectTiled
Function DrawImageRectTiled(img:TImage, x:Int, y:Int, width:Int, height:Int, frame:Int = 0)
	Local i:Int
	Local h:Int
	Local imgWidth:Int = img.width
	Local imgHeight:Int = img.height
	
	' Save viewport
	Local vpX:Int
	Local vpY:Int
	Local vpWidth:Int
	Local vpHeight:Int
	GetViewport vpX, vpY, vpWidth, vpHeight
	
	' Set viewport
	SetViewport x, y, width, height
	For i = 0 To width / imgWidth
		For h = 0 To height / imgHeight
			DrawImage img, x + i * imgWidth, y + h * imgHeight, frame
		Next
	Next
	
	' Reset viewport
	SetViewport vpX, vpY, vpWidth, vpHeight
End Function

' ResetMax2D
Function ResetMax2D()
	SetTransform
	SetAlpha 1
	SetColor 255, 255, 255
End Function
